package xc.service;

import xc.dao.RoomDao;
import xc.entity.Room;

import java.sql.SQLException;

public class RoomService {

    private RoomDao roomDao;

    public  RoomService(){
        this.roomDao = new RoomDao();
    }

    public void updateRoom(String roomName,String roomStatus) throws SQLException {
        if (roomDao.existRoom(roomName)) {
            roomDao.updateRoom(roomName,roomStatus);
        }else {
            System.out.println("房间不存在");
        }
    }

    public boolean addRoom(Room room) throws SQLException {
        if (!roomDao.existRoom(room)) {
            roomDao.addRoom(room);
            return true;
        }else {
            System.out.println("房间已存在");
            return false;
        }
    }

    public boolean deleteRoom(String roomName) throws SQLException {
        if (roomDao.existRoom(roomName)) {
            roomDao.deleteRoom(roomName);
            return false;
        }else  {
            System.out.println("房间不存在");
            return true;
        }
    }

    public void selectRoom() throws SQLException {
        roomDao.selectRoom();
    }
}
